<template>
  <!-- 一行三列视频列表 -->
  <view class="video-list">
    <view class="video-item" 
      v-for="item in videoList" 
      :key="item.id"
      @click="goVideoDetail(item.id)"
      :data-id="item.id"
    >
      <view class="video-cover-img">
        <image class="preview-img" :src="item.images"></image>
      </view>
      <view class="video-bottom">
        <view class="video-name">{{item.name}}</view>
        <view class="actor">{{item.author}}</view>
      </view>
    </view>
    <div class="placeholder"></div>
  </view>
</template>

<script>
export default {
  name: 'video-list',
  components: {},
  data() {
    return {}
  },
  props: {
    videoList: {
      type: Array,
      default() {
        return []
      }
    },
    // 跳转详情方式 navigateTo redirectTo reLaunch
    jumpType: {
      type: String,
      default: 'navigateTo'
    }
  },
  created() {},
  mounted() {},
  methods: {
    goVideoDetail(videoId) {
      if (this.jumpType === 'navigateTo') {
        uni.navigateTo({url: `/pages/video/video?id=${videoId}`});
      } else if (this.jumpType === 'redirectTo') {
        uni.redirectTo({url: `/pages/video/video?id=${videoId}`});
      }
    }
  }
};
</script>
<style lang="scss" scoped>
  .video-list {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: space-between;
    .video-item {
      width: 30%;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-bottom: 30rpx;
      .video-cover-img {
        .preview-img {
          width: 200rpx;
          height: 240rpx;
          display: block;
          border-radius: 10rpx;
        }
      }
      .video-bottom {
        width: 100%;
        margin-top: 10rpx;
        .video-name, .actor {
          font-size: 22rpx;
          color: #999;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow-x: hidden;
          text-align: center;
        }
        .actor {
          margin-top: 4rpx
        }
      }
    }
    .placeholder {
      width: 30%;
      height: 0;
    }
  }
</style>